<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="white" />
    <title></title>
    <link rel="stylesheet" href="../public/css/weui.css" />
    <link rel="stylesheet" href="../public/css/jquery-weui.css" />
    <link rel="stylesheet" href="../public/css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
	<style>
		[v-cloak]{
			display:none;
		}
	</style>
</head>
<body style="background: #FFFFFF;">
<div id="createorder" v-cloak>
	<div>
		<div style="height: 1.8rem;"></div>
		<div class="public_top_header">
			<a href="javascript:history.back(-1)" class="weui-cell">
				<div class="weui-cell__hd">
					<img src="../public/images/jiantouleft.png" />
				</div>
				<div class="weui-cell__bd">矿机购买</div>
			</a>
		</div>
	</div>
	<div class="buycarlist">
		<div class="mill-msg">
			<div class="number">{{millname}}</div>
			<div class="other-msg weui-cell">
				<div class="weui-cell__hd">
					<img src="../public/images/buy1.png" />
				</div>
				<div class="weui-cell__bd">
					<div class="item">收益:<span>{{milldetail.rate*100}}%</span></div>
					<div class="item">算力天数:<span>{{milldetail.daysNum}}</span>天</div>
					<div class="item">每日算力:<span>{{milldetail.arithmeticStrength}}</span></div>
				</div>
			</div>
		</div>
		<div class="selectlines">
			<div class="title">矿机额度</div>
			<div class="list">
				<div class="item" :class="{'active':item.isselect}" v-for="(item,index) in lineslist[millid-1]" @click="selectline(index)">
					{{item.amount}}
				</div>
				<div class="clearfloat"></div>
			</div>
		</div>
		<div class="weui-cell buynum">
			<div class="weui-cell__bd">购买数量</div>
			<div class="weui-cell__ft">
				<img src="../public/images/addmill.png" class="jia" @click="addnum" />
				<div class="num">{{buynum}}</div>
				<img src="../public/images/reduce.png" class="jian" @click="reducenum" />
			</div>
		</div>
	</div>
	<div style="height: 0.96rem;"></div>
	<div class="buycarfooter weui-cell">
		<div class="weui-cell__bd">合计：<span>{{sumCode}}</span> 云币共<span>{{buynum}}</span>个矿机</div>
		<div class="weui-cell__ft" @click="pay()">立即支付</div>
	</div>
</div>
<script type="text/javascript" src="../public/js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="../public/js/vue.js" ></script>
<script type="text/javascript" src="../public/js/jquery-weui.js" ></script>
<script type="text/javascript" src="../public/js/font_size.js" ></script>
<script type="text/javascript" src="../public/js/common.js" ></script>
<script type="text/javascript">
    $(function(){
        var vm = new Vue({
            el:"#createorder",
            data: {
            	buynum:1,
				millname:0,
				sumCode:0,
				millid:0,
                milldetail:{
                    daysNum:0,
                    arithmeticStrength:0,
                    rate:0
				},
            	lineslist:[[{
                    amount:2000,
                    isselect:true
                },{
                    amount:3000,
                    isselect:false
                },{
                    amount:4000,
                    isselect:false
                },{
                    amount:5000,
                    isselect:false
                },{
                    amount:6000,
                    isselect:false
                },{
                    amount:7000,
                    isselect:false
                },{
                    amount:8000,
                    isselect:false
                },{
                    amount:9000,
                    isselect:false
                },{
                    amount:10000,
                    isselect:false
                }],[{
                    amount:11000,
                    isselect:true
                },{
                    amount:13000,
                    isselect:false
                },{
                    amount:15000,
                    isselect:false
                },{
                    amount:17000,
                    isselect:false
                },{
                    amount:19000,
                    isselect:false
                },{
                    amount:21000,
                    isselect:false
                },{
                    amount:23000,
                    isselect:false
                },{
                    amount:25000,
                    isselect:false
                },{
                    amount:30000,
                    isselect:false
                }],[{
                    amount:31000,
                    isselect:true
                },{
                    amount:32000,
                    isselect:false
                },{
                    amount:3400,
                    isselect:false
                },{
                    amount:35000,
                    isselect:false
                },{
                    amount:36000,
                    isselect:false
                },{
                    amount:37000,
                    isselect:false
                },{
                    amount:38000,
                    isselect:false
                },{
                    amount:39000,
                    isselect:false
                },{
                    amount:40000,
                    isselect:false
                }],[{
                    amount:41000,
                    isselect:true
                },{
                    amount:43000,
                    isselect:false
                },{
                    amount:44000,
                    isselect:false
                },{
                    amount:45000,
                    isselect:false
                },{
                    amount:46000,
                    isselect:false
                },{
                    amount:47000,
                    isselect:false
                },{
                    amount:48000,
                    isselect:false
                },{
                    amount:49000,
                    isselect:false
                },{
                    amount:50000,
                    isselect:false
                }],[{
                    amount:51000,
                    isselect:true
                },{
                    amount:53000,
                    isselect:false
                },{
                    amount:54000,
                    isselect:false
                },{
                    amount:55000,
                    isselect:false
                },{
                    amount:56000,
                    isselect:false
                },{
                    amount:57000,
                    isselect:false
                },{
                    amount:58000,
                    isselect:false
                },{
                    amount:59000,
                    isselect:false
                },{
                    amount:60000,
                    isselect:false
                }]]
            },
            methods:{
				selectline:function(index){
				    var item=this.lineslist[this.millid-1]
					for(var i=0;i<item.length;i++){
						item[i].isselect = false;
					}
					item[index].isselect = true;
					this.sumCode=parseInt(item[index].amount*this.buynum)
				},
				addnum:function(){
					this.buynum++;
                    this.sumCode=this.lineslist[this.millid-1].filter(function(el){
                        return el.isselect
                    })[0].amount * this.buynum
				},
				reducenum:function(){
					if(this.buynum>1){
						this.buynum--;
                        this.sumCode=this.lineslist[this.millid-1].filter(function(el){
                            return el.isselect
                        })[0].amount * this.buynum
					}else{
						$.alert({
						  title: '提示',
						  text: '数量至少为一个',
						  onOK: function () {
						    //点击确认
						  }
						});
					}
				},
				pay:function () {
				    var money=this.lineslist[this.millid-1].filter(function(el){
                        return el.isselect
                    })[0].amount
                    local.saveData("millorder",{
                        money,
						num:this.buynum,
					})
					$(window).attr("location","./moneyPassword.html")
                }
            },
			watch:{
			},
            created:function(){
            	this.millname=local.getData("milldetail").millname;
            	this.millid=local.getData("milldetail").millid;
            	this.sumCode=this.lineslist[this.millid-1].filter(function(el){
                    return el.isselect
                })[0].amount;
            	AjaxRequest({
					url:_url+"/money//mill/milldetail",
					load:true,
					data:{millid:this.millid},
					type:"post",
					success(res){
					    if(isReqSucceed(res)){
                            vm.milldetail.daysNum=res.data.daysNum;
                            vm.milldetail.arithmeticStrength=res.data.arithmeticStrength;
                            vm.milldetail.rate=res.data.rate;
						}
					}
				});
            }
        })
    })
</script>
</body>
</html>



